import json

import requests

def get_avaxScan_data(tx_hash):
    # 交易网站的网址
    url=f'https://avascan.info/react-api/network/mainnet/blockchain/2q9e4r6Mu3U68nU1fYjgbR6JvwrRx36CohpAX5UQxse55x1Q5/tx/0x{tx_hash}?ecosystem=avalanche'

    headers = {
            'User-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0'
        }
    response = requests.get(url=url,headers=headers)

    if response.status_code == 200:
        print("AVAX链数据爬取完成！")
        # json_data = json.dumps(response.json(), indent=4)
        # with open('../data/avaxdata.json', 'w', encoding='utf-8') as f:
        #     f.write(json_data)
        return response.json()
    else:
        print(f"Error: {response.status_code}, {response.text}")
# get_avaxScan_data("07FF85ED35AA1BC3D63151EA2902AD1A675C4E2968AF6EC76F24A9B05CEE09B3")

